﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XCommunity.Frames;
using XCommunity.Views;

namespace XCommunity.Forums.Views
{
  public class TopicFrameView : ViewObject
  {

    public TopicFrameView( ForumsViewService service, GeneralTopicFrame topic )
      : base( service )
    {
      Service = service;
      Topic = topic;
    }

    protected new ForumsViewService Service
    {
      get;
      private set;
    }

    public GeneralTopicFrame Topic
    {
      get;
      private set;
    }




    public GeneralPostFrameView Theme
    {
      get { return Service.GetPostFrameView( Topic.Theme ); }
    }

    public IEnumerable<PostFrameView> Responses
    {
      get
      {
        var responses = from post in Topic.Responses
                        where !post.Removed
                        select Service.GetPostFrameView( post );

        return Service.GetFilters( this, "Responses" ).Filter( responses );
      }
    }



    public override object BaseObject
    {
      get { return Topic; }
    }
  }
}